<div class="form-area" id="base-form">
<form id="form-base" action="/invitation/basic_save" method="post">
<input type="hidden" name="method" value="do"/>
<input type="hidden" name="CSRFToken" value="${CSRFToken!}"/>
<input type="hidden" name="type" value="basic">
<input type="hidden" name="mobile" value="${invitationApply.mobile}" id="mobile_base"/>
<table width="100%" class="dj-form-base copy">
<colgroup>
    <col width="200">
    <col width="*">
</colgroup>
<tbody>
<tr>
    <th><em>*</em>姓名:</th>
    <td class="input">
        <input type="text" autocomplete="off" id="employer-input"
               class="text J_checkBase J_able_b" name="name" reg="^([\u4e00-\u9fa5]){2,5}$" ajaxreg="name:namecallback" ajaxcheck="true"
               maxlength="5" value="${(invitationApply.basicInfo.name)!}" 
               <#if invitationApply?? && invitationApply.basicInfo.name?? && invitationApply.basicInfo.name!="">readOnly="true"</#if> 
               >
        <em class="sync"></em>
        <div style="display:none;" class="error">请填写真实姓名，2-5个汉字</div>
    </td>
</tr>
<tr>
    <th><em>*</em>性别:</th>
    <td>
    <#list dictMap.DICT_GENDER.data as item>
        <input type="radio" name="gender" class="J_checkBase J_able_b" 
        	onclick="saveGender(this.value)" id="gender_${item.id}"
        	value="${item.id?c}"<#if invitationApply.basicInfo.gender?? && invitationApply.basicInfo.gender==item.id> checked="checked"</#if>/><label class="radio" <#if item.id == 1>style="margin-right:15px;"</#if> for="gender${item.id?c}">${item.name}</label>
    </#list>
    <@holder>
        <script type="text/javascript">
            function validateGenderInput(){
                return $('#basic-form :input[name="gender"]:checked').val();
            }
        </script>
    </@holder>
    <div style="display: none; " class="error" id="error_gender">请选择性别</div>
    </td>
</tr> 
<@holder>
<script type="text/javascript">
    $('#domicile-linkup').linkup({type: 'city'});
</script>
</@holder>
<tr>
    <th><em>*</em>出生日期:</th>
    <td class="input">
    <#assign startyear=currentDate?string('yyyy')?number?int-53 />
    <#assign endyear=currentDate?string('yyyy')?number?int-16 />
    <@dateinput name="birthday" id="profile-birthdate-input" startyear=startyear endyear=endyear value=(invitationApply.basicInfo.birthday?string("yyyy-MM-dd"))!'' class="J_checkBase J_able_b"/>
        <div style="display: none; " class="error" id="error_profile-birthdate-input">请选择出生日期</div>
    </td>
</tr>
<tr>
    <th>户口地:</th>
    <td class="input" id="domicile-linkup">
    <#assign domicileParentId = 0 />
    <#assign domicileId = 0 />
    <#if invitationApply.basicInfo.domicile??>
        <#assign domicileParentId = (dictMap.DICT_CITY.map.get(invitationApply.basicInfo.domicile).parentId)!0 />
        <#assign domicileId = invitationApply.basicInfo.domicile />
    </#if>
        <select style="width:80px" class=" city J_able_b" >
            <option value="">请选择</option>
        <#list dictMap.DICT_CITY.data as item>
            <#if item.id lt 910000>
                <option value="${item.id?c}"<#if domicileParentId==item.id || domicileId==item.id> selected</#if>>${item.name}</option>
            </#if>
        </#list>
        </select>
        <select style="width:80px" name="domicile" class=" city J_able_b" id="basic-domicile-select">
        <#if domicileId!=0>
            <#if domicileParentId!=0>
                <#assign itemList = (dictMap.DICT_CITY.map.get(domicileParentId).children)! />
            <#else>
                <#assign itemList = (dictMap.DICT_CITY.map.get(domicileId).children)! />
            </#if>
            <#if !itemList?? || itemList?size==0>
                <#if (domicileId)?? &&(dictMap.DICT_CITY.map)?? && (dictMap.DICT_CITY.map.get(domicileId))??>
                    <option value="${domicileId}">${dictMap.DICT_CITY.map.get(domicileId).name}</option>
                </#if>
            <#else>
                <#list itemList as item>
                    <option value="${item.id?c}"<#if domicileId == item.id> selected</#if>>${item.name}</option>
                </#list>
            </#if>
        </#if>
        </select>
        <script type="text/javascript">
            $('#domicile-linkup').linkup({type: 'city'});
        </script>
        <div style="display:none;" class="error">请选择户口所在地区</div>
    </td>
</tr>
<tr>
    <th><#if navStatus?? && navStatus ==1><em>*</em></#if>工作经验:</th>
<#if invitationApply.basicInfo.workYears??>
    <#assign wYear = invitationApply.basicInfo.workYears -1 >
</#if>
    <td class="input">
        <select name="workYear" id="work-start-year-input"
                style="width:110px" <#if navStatus?? && navStatus ==1>class="J_checkBase  J_able_b"<#else>blanksubmit="true" class="J_able_b"</#if>>
            <option value="">请选择</option>
            <option <#if wYear?? && wYear lte 0>selected="selected" </#if> value="1">刚参加工作</option>
            <option <#if wYear?? && wYear == 1>selected="selected" </#if> value="2">已工作1年</option>
            <option <#if wYear?? && wYear == 2>selected="selected" </#if> value="3">已工作2年</option>
            <option <#if wYear?? && wYear == 3>selected="selected" </#if> value="4">已工作3年</option>
            <option <#if wYear?? && wYear == 4>selected="selected" </#if> value="5">已工作4年</option>
            <option <#if wYear?? && wYear == 5>selected="selected" </#if> value="6">已工作5年</option>
            <option <#if wYear?? && wYear == 6>selected="selected" </#if> value="7">已工作6年</option>
            <option <#if wYear?? && wYear == 7>selected="selected" </#if> value="8">已工作7年</option>
            <option <#if wYear?? && wYear gt 7>selected="selected" </#if> value="9">8年及以上</option>
        </select>
        <div style="display: none;" class="error">请选择工作经验</div>
    </td>
</tr> 
<tr>
    <th>QQ:</th>
    <td class="input">
        <input type="text" reg="numeric" class="text J_checkContact  J_able_b" maxlength="50" id="qq" name="qq" value="${(invitationApply.basicInfo.qq)!}" blanksubmit="true"                            >

        <div style="display: none; " class="error"> 请输入正确QQ号</div>
    </td>
</tr>
<tr>
    <th>&nbsp;</th>
    <td class="input button" style="display: none;">
        <a href="javascript:void(0);" itemtype="base" class="fresh formValidateSubmit margin"  
           id="J_baseSubmit"><span>保存</span></a>
        <a href="javascript:void(0);" style="display:none" class="normal J_cancel" itemtype="base"><span>取消</span></a>
    </td>
</tr>
</tbody>
</table>
</form>
<script type="text/javascript">

    $.formValidate.ajaxtype.name='http://job.dajie.com/resume/basic/name/blackCheck'
    function namecallback(r)
    {
        if(r == false)
        {
            $(this).parents('td').find('.error').show()
        }
    }
    
    
    var saveGender = function( vl )
    {
    	$.ajax({
    		url:'/ajax/savegender',
    		data:{gender:vl,mobile:$("#mobile_base").val()},
    		dataType : 'text',
    		timeout : 5000,
    		type : 'POST',
    		error: function(r){ },
    		success:function(r)
    		{
    			
    		}
    	});
    	
    }
    
    
    var checkBaseItem = function()
    {
    	if($("#name").val() != "" && $("#gender").val()!="" && $("#profile-birthdate-input").val() != ""
    		&& $("#basic-domicile-select").val() != "")
    	{
            $("#J_baseSubmit").attr("class","normal");
    	}
    }
    
    var savebirthday = function (vl)
	{
		if(vl.length != 10)	return ;
		$.ajax({
    		url:'/ajax/savebirthday',
    		data:{birthday:vl,mobile:$("#mobile_base").val()},
    		dataType : 'text',
    		timeout : 5000,
    		type : 'POST',
    		error: function(r){ },
    		success:function(r)
    		{
    			
    		}
    	});
		
	}
    
    
    $("#basic-domicile-select").change(function()
    {
    	savedomicile($("#basic-domicile-select").val());
    });

	var savedomicile = function (vl)
	{
		if(vl.length == "")	return ;
		$.ajax({
    		url:'/ajax/savedomicile',
    		data:{domicile:vl,mobile:$("#mobile_base").val()},
    		dataType : 'text',
    		timeout : 5000,
    		type : 'POST',
    		error: function(r){ },
    		success:function(r)
    		{
    		}
    	});
	}   
    
    var saveworkyears = function( vl )
    {
    	if(vl == "") return;
    	$.ajax({
    		url:'/ajax/saveworkyears',
    		data:{workyears:vl,mobile:$("#mobile_base").val()},
    		dataType : 'text',
    		timeout : 5000,
    		type : 'POST',
    		error: function(r){ },
    		success:function(r)
    		{
    			
    		}
    	});
    }
    
    var saveqq = function( vl )
    {
    	if(vl == "") return;
    	$.ajax({
    		url:'/ajax/saveqq',
    		data:{qq:vl,mobile:$("#mobile_base").val()},
    		dataType : 'text',
    		timeout : 5000,
    		type : 'POST',
    		error: function(r){ },
    		success:function(r)
    		{
    			
    		}
    	});
    }
    
    $(function() 
    {
    	$("#qq").change(function()
    	{
    		saveqq($("#qq").val());
    	});
    
    	$("#work-start-year-input").change(function(obj)
    	{
    		saveworkyears($("#work-start-year-input").val());
    	});
    	
    	$("#profile-birthdate-input-year").change(function()
		{
			savebirthday($("#profile-birthdate-input").val());
		});
	    	
	    $("#profile-birthdate-input-month").change(function()
	    {
			savebirthday($("#profile-birthdate-input").val());
	    });
	    
	    $("#profile-birthdate-input-date").change(function()
	    {
			savebirthday($("#profile-birthdate-input").val());
	    });
    
    	checkBaseItem();	
		$(".J_able_b").change(function()
		{
			$("#J_baseSubmit").attr("class","fresh formValidateSubmit margin");
		});    
    
        var $checks = $('.J_checkBase'), $btnO = $('#J_baseSubmit'), flag = true;
        $checks.formValidate();
        $checks.focus(function () 
        {
            $(this).parents('td').find('.error').hide();
        });
        $('.text').focus(function()
        {
            $(this).parents('td').find('.error').hide();
        });

        $btnO.click(function (e) 
        {
        	res = true;
            e.preventDefault();
            var itemType = $(this).attr('itemtype');
            $checks.each(function () 
            {
                var e = $.formValidate.check(this);
                if (!e) 
                {
                    $(this).parents('td').find('.error').show();
                    res = false
                }
            });
            //$.formValidate.submit(function(res)
            {
                if(res)
                {
                    $checks.each(function()
                    {
                        var $this = $(this);
                        var bv = $this.attr('blankvalue');
                        if(bv && bv == $this.val())
                        {
                            $this.val('');
                        }
                    });
                    formSubmit($('#form-base'),itemType);
                    $("#J_baseSubmit").attr("class","normal");
                }
            }//);
            //formSubmit($('#form-base'),itemType);
        });
    });


    function _GapCheck() 
    {
        var val = $(this).val()
        if (/^[0-5]+(\.\d{1,2})?$/.test(val)) 
        {
            return val<=5
        }
    }


	

</script>
</div>
